package org.pisces.wechat.commons.exception;

import java.util.HashMap;
import java.util.Map;

/**
 * 系统错误编码定义
 * 内部错误~100000
 * 授权登陆~200000
 */
public class ErrorCode {

	/**系统错误*/
	public static final int SYSTEM_ERROR = 100000;
	
	/**参数错误*/
	public static final int PARAM_ERROR = 100001;
	
	/**
	 * 服务尚未实现
	 */
	public static final int SERVICE_NOT_IMPLEMENTS = 100002;
	
	/**记录已经存在*/
	public static final int RECORD_EXSIT_ERROR = 100005;
	
	/**记录已经存在，其他信息不符*/ 
	public static final int RECORD_EXSIT_OTHER_ERROR = 100006;
	
	/**参数超过最大限制*/
	public static final int PARAM_TO_LONG_ERROR = 100010;
	
	/**记录不存在*/
	public static final int RECORD_NOT_EXSIT_ERROR = 100015;
	
	/**参数不能为空*/
	public static final int PARAM_NULL_ERROR = 100020;
	
	/**权限不足*/
	public static final int PERMISSION_DENIED_ERROR = 100025;
	
	/**对象不能修改*/
	public static final int UNABLE_MODIFY_ERROR = 100030;
	
	/**
	 * 账号或密码错误
	 */
	public static final int G_LOGIN_NAME_OR_PASSWORD_ERROR = 200000;
	
	/**
	 * 账号被禁用
	 */
	public static final int G_ACCOUNT_DISABLED_ERROR = 200001;
	
	/**
	 * TGT已失效
	 */
	public static final int G_TGT_INVALID_ERROR = 200010;
	/**
	 * ST已失效
	 */
	public static final int G_ST_INVALID_ERROR = 200011;
	
	/**错误消息容器*/
	private static final Map<Integer, String> ERROR_MESSAGE_MAP = new HashMap<Integer, String>();
	
	
	static{
		ERROR_MESSAGE_MAP.put(SYSTEM_ERROR, "系统出现异常");
		ERROR_MESSAGE_MAP.put(PARAM_ERROR, "请检查参数是否正确");
		ERROR_MESSAGE_MAP.put(SERVICE_NOT_IMPLEMENTS, "服务暂未实现.");
		ERROR_MESSAGE_MAP.put(PARAM_TO_LONG_ERROR, "记录已经存在");
		ERROR_MESSAGE_MAP.put(PARAM_TO_LONG_ERROR, "参数超出最大长度限制");
		ERROR_MESSAGE_MAP.put(RECORD_NOT_EXSIT_ERROR, "记录不存在");
		ERROR_MESSAGE_MAP.put(PARAM_NULL_ERROR, "请求参数不能为空");
		ERROR_MESSAGE_MAP.put(PERMISSION_DENIED_ERROR, "权限不足");
		ERROR_MESSAGE_MAP.put(UNABLE_MODIFY_ERROR, "对象不能修改");
		
	}
	
	
	public static String getErrorMessage(int errorCode){
		if(ERROR_MESSAGE_MAP.containsKey(errorCode)){
			return ERROR_MESSAGE_MAP.get(errorCode);
		}else{
			return "系统维护中";
		}
	}
}